//
//  lastUPTableViewCell.m
//  A段项目,漫画
//
//  Created by dllo on 15/4/23.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "lastUPTableViewCell.h"
#define WIDTH [[UIScreen mainScreen] bounds].size.width
@implementation lastUPTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.lastup = [[UILabel alloc] init];
        [self.contentView addSubview:self.lastup];
        [self.lastup release];
        
        self.update_date = [[UILabel alloc] init];
        [self.contentView addSubview:self.update_date];
        [self.update_date release];
        
        self.lastUpButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:self.lastUpButton];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.lastup.frame = CGRectMake(20, 10, WIDTH / 6, WIDTH / 7 / 1.5);
    self.lastup.text = @"最新话:";
    self.lastup.textAlignment = NSTextAlignmentCenter;
    self.lastup.font = [UIFont systemFontOfSize:14];
    
    self.update_date.frame = CGRectMake(20 + WIDTH / 6 + 20+ WIDTH / 7 + 10, 5, WIDTH / 2, WIDTH / 7 / 1.5 + 10);
    self.update_date.font = [UIFont systemFontOfSize:14];
    self.update_date.numberOfLines = 0;
    self.update_date.textAlignment = NSTextAlignmentCenter;
    
    self.lastUpButton.frame = CGRectMake(20 + WIDTH / 6 + 20, 10, WIDTH / 7, WIDTH / 7 / 1.5);
    self.lastUpButton.layer.borderWidth = 1;
    self.lastUpButton.layer.cornerRadius = 5;
    [self.lastUpButton addTarget:self action:@selector(lastUpButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)lastUpButtonAction:(UIButton *)button{
    NSString *lastUpStr = self.lastUpButton.titleLabel.text;
    NSLog(@"最新话   %@",lastUpStr);
    self.myBlock(lastUpStr);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
